function mapChildren(reactChildren, func, context) {
    //TODO实现此mapChildren方法
    if(!Array.isArray(reactChildren)) return reactChildren
    let idx = 0

    function invoke(reactChildren,func,idx){
        reactChildren = reactChildren.reduce((pre,cur)=>{
            if(Array.isArray(cur)){
               let resultArr = invoke(cur,func,idx)
               let tempArr =  [...pre,...resultArr]
               idx += tempArr.length -1
              return tempArr
            }else if((typeof cur === 'object' && cur===null ) || typeof cur === 'undefined' ){
                return pre
            }else{
                pre.push(func(cur,idx++) )
            }
            return pre
        },[])
        return reactChildren
    }

    return  invoke(reactChildren, func, idx);
}

export {
    mapChildren as map,
};